home *** CD-ROM | disk | FTP | other *** search
/ ftp.sunet.sepub/pictures / 2014.11.ftp.sunet.se-pictures.tar / ftp.sunet.se / pub / pictures / ACiD-artpacks / programs / mac / maczipit138.hqx / ZipIt 1.3.8 / ZipIt docs.rsrc / TEXT_133.txt < prev    next >
Text File  |  1997-09-01  |  3KB  |  40 lines

  1. Scripting ZipIt
  2.  
  3. Starting with version 1.3.7, ZipIt is fully scriptable. This means that you can do anything via AppleScript that you can manually. The scripting capability is very powerful; this section is meant to provide a taste of a few things that can be done with it. If you need more detailed help, you can always send me email.
  4.  
  5. There are a number of different types of objects that ZipIt defines to make scripting easier:
  6.  
  7. ΓÇó a window is synonymous with a document, and refers to an open zip archive
  8. ΓÇó an entry refers to a file or folder within a zip archive
  9. ΓÇó a file refers to a file within a zip archive
  10. ΓÇó a folder refers to a folder within a zip archive
  11.  
  12. Entries, files, and folders are numbered separately, so if you have an archive that consists of a file and then a folder, folder 1 will refer to the folder, file 1 will refer to the file, and entry 1 will refer to the file, and entry 2 will refer to the folder. Also, entries, files, and folders are numbered relative to the current window unless you specify otherwise. File 1, in other words, refers to the first file in the window, not the first file in the archive. To see the significance of this, suppose you open an archive with a folder in it. You then open the folder. File 1 now refers to the first file in the folder that you just opened - in other words, it changed, now that youΓÇÖve opened a folder. Absolute references are possible by the use of the ΓÇ£rootΓÇ¥ property of a window or document. To refer to the first file in the archive, you can refer to ΓÇ£file 1 of root of window 1ΓÇ¥. The root is the topmost level of the archive. Whenever ZipIt returns an object reference, it always refers to it from the root to avoid confusion.
  13.  
  14. Each object has elements and properties, which are listed fully in ZipItΓÇÖs dictionary (choose Open Dictionary in Script Editor to see ZipItΓÇÖs AppleScript dictionary). Windows and documents contain entries, files, and folders as elements, so you can refer to a file by saying ΓÇ£file 1 of window 1ΓÇ¥. You can also use names, e.g., ΓÇ£file "test" of window "archive.zip"ΓÇ¥.
  15.  
  16. To zip files:
  17.  
  18. tell application "ZipIt"
  19.     activate
  20.     set file_to_zip to (choose file)
  21.     set zip_archive to (make new window at the beginning)
  22.     add file_to_zip to zip_archive
  23.     compress zip_archive to file "Hard disk:Desktop folder:archive.zip"
  24. end tell
  25.  
  26. The variable file_to_zip, above, can also be a list of files or folders.
  27.  
  28. To unzip an archive:
  29.  
  30. tell application "ZipIt"
  31.     activate
  32.     set archive_to_unzip to (choose file)
  33.     open archive_to_unzip
  34.     extract every entry in window 1 into file "Hard disk:desktop folder:" -- Note the use  of the 'file' keyword here
  35. end tell
  36.  
  37. To create a new folder, say ΓÇ£make new folder at end of window 1 with properties {name:"foldername"}ΓÇ¥. As an alternative to the ΓÇ£addΓÇ¥ command, if you want more control (but less intuitiveness), you can write ΓÇ£make new file at end of window 1 with properites {disk file: file "whatever"}ΓÇ¥. You can naturally also specify other properties in the make command.
  38.  
  39. If you have further questions about scripting, the ZipIt homepage may have an answer to your question (see the introductory section for the URL). Otherwise, feel free to send me email.
  40.